import {Injectable} from '@angular/core';
import {BaseHttpService} from '../base-http.service';
import {Observable} from 'rxjs';
import {MsdsEnterpriseList, PageInfo, SearchCommonVO} from '../../types';

export interface MsdsEnterprise {
  entprEmergentPhone?: string;
  cnName: string;
  countryEmergentPhone?: string;
  effectDate: Date,
  enName?: string;
  entprAddress?: string;
  entprFax?: string;
  construction?: string;
  entprName?: string;
  entprPhone?: string;
  formula?: string;
}

@Injectable({
  providedIn: 'root'
})
export class MsdsHttpService {

  constructor(public http: BaseHttpService) {
  }

  /*查询化学品及企业标识*/
  public getMsdsList(param: SearchCommonVO<any>): Observable<PageInfo<MsdsEnterpriseList>> {
    return this.http.post('/msdsEnterprise/list', param);
  }

  /*新增msdsEnterprise信息*/
  public addMsds(param: MsdsEnterprise): Observable<any> {
    return this.http.post('/msdsEnterprise', param, {needSuccessInfo: true});
  }

  /*修改msdsEnterprise信息*/
  public editMsds(param: MsdsEnterprise): Observable<any> {
    return this.http.put('/msdsEnterprise', param, {needSuccessInfo: true});
  }

  /*查询msdsEnterprise详情*/
  public getMsdsDetail(id: number): Observable<MsdsEnterprise> {
    return this.http.get('/msdsEnterprise/' + id);
  }

  /*删除msdsEnterprise信息*/
  public delMsdsList(ids: number[]): Observable<void> {
    return this.http.post('/msdsEnterprise/del', {ids: [ids]}, {needSuccessInfo: true})
  }

  /*msdsWord文档导出*/
  public getMsdsExport(id: number): Observable<any> {
    return this.http.downZip(`/word/msds-export?id=${id}`)
  }

  /*安全标签文档导出*/
  public getSafetyExport(id: number): Observable<any> {
    return this.http.downZip(`/word/safety-export?id=${id}`)
  }

}

